$(document).ready(function(){
  $(".head-s").mouseenter(function(){
    $("ul.set").css("display","block");
  }).mouseleave(function(){
    $("ul.set").css("display","none");
  });
  $("#cancel").click(function (){
      $(".confir").css('display','none')
  });
  $("#submit").click(function (){
      one_pwd = $(".new1").val()
      two_pwd = $(".new2").val()
      if(!one_pwd){
        $(".new1").css('border-color', 'red')
          return false;
      }
      if(!two_pwd){
        $(".new2").css('border-color', 'red')
          return false;
      }
      if(one_pwd !== two_pwd){
          $("div.confir > div > div:nth-child(2)").append("<p style='color: red' id='errmsg'>两次密码不一致！</p>")
          return false;
      }
      $.ajax({
          url: '/user/reset/',
          type:'POST',
          data:{
              'password': one_pwd
          },
          success: function (){
              window.location.href = '/'
              },
      })
  });
  $("#change-pwd").click(function () {
      $(".confir").css('display', 'block')
  });
  $("#logout").click(function (){
      $.ajax({
          url: '/logout/',
          type: 'POST',
          success: function() {
              window.location.href = '/'
          }
      })
  })
});